""" 配置文件 """
import os
from datetime import timedelta

class Config:
    """ 配置类 """
    # 基础配置
    SECRET_KEY = os.getenv('SECRET_KEY', 'dev-key-change-me')

    # 数据库
    SQLALCHEMY_DATABASE_URI = 'mysql+mysqlconnector://root:123456@localhost/mydb'
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    SQLALCHEMY_ENGINE_OPTIONS = {
        'pool_size': 10,
        'pool_recycle': 300,
        'pool_pre_ping': True
    }

    # JWT
    JWT_SECRET_KEY = os.getenv('JWT_SECRET_KEY', 'jwt-secret-change-me')
    JWT_ACCESS_TOKEN_EXPIRES = timedelta(hours=1)
    JWT_TOKEN_LOCATION = ['headers']

    # 上传
    UPLOAD_FOLDER = 'static/uploads'
    MAX_CONTENT_LENGTH = 16 * 1024 * 1024  # 16MB

    # 速率限制
    RATELIMIT_DEFAULT = "200 per day;50 per hour"

